import { computed, ref } from 'vue'
import { createGlobalState, useStorage } from '@vueuse/core'
export const useGlobalState = createGlobalState(() => {
  // state
  const count = ref(0)
  const message = useStorage('message', '你好', sessionStorage)
  // getters
  const doubleCount = computed(() => count.value * 2)
  // actions
  function increment() {
    count.value++
    message.value += '!'
  }
  return { count, message, doubleCount, increment }
})
